#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：9.用户登录.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-10-30 16:14
'''

# 自定义异常一定要继承Exception
class LoginError(Exception):
    def __str__(self):
        return "用户名或密码错误"

    def __repr__(self):
        return "用户名或密码错误..."

name = input("请输入用户名：")
password = input("请输入密码：")

local_name = "夏洛"
local_password = "123456"

try:
    if password != local_password or name != local_name:
        raise LoginError
except LoginError as e:
    print(f"登录失败：{e}")